<?php
/**
 * $Id: default.php 11917 2009-05-29 19:37:05Z ian $
 */
defined( '_JEXEC' ) or die( 'Restricted access' );

$cparams = JComponentHelper::getParams ('com_media');
?>
<div style="display: none;position: fixed; top: 0;left: 0;width: 100%;height: 100%;background-color: #000000;z-index:10000;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);" id="backoverlay"></div>

<div class="template-section">
		<div class="heading">
			<h2>Kontakt</h2>
		</div>
		<div class="clear-fix" id="contact-section">
			<div id="contact-left">
				<h1>Dyrecoach</h1>
			<p></p><?php echo $this->contact->address; ?></p>
				<p>Email <a href="mailto:<?php echo $this->contact->email_to; ?>"><?php echo $this->contact->email_to; ?></a></p>
				<p>Tlf: <?php echo $this->contact->telephone; ?></p>
			</div><!--  end contact left  -->
			<div id="contact-right">
				<form action="<?php echo JRoute::_('index.php') ?>" method="post" name="selectForm" id="selectForm">
					<fieldset>
						<input type="text" class="txtInput_toggle" value="Kontaktperson" name="kontaktperson" id="kontaktperson" />
						<input type="text" class="txtInput_toggle" value="Email" name="email" id="email" />
						<input type="text" class="txtInput_toggle" value="Firma/navn" name="navn" id="navn"/>
						<input type="text" class="txtInput_toggle" value="Emne" name="emne" id="emne" />
						<textarea cols="" rows="" class="txtInput_toggle" name="text" id="text" >Din besked</textarea>
						<div class="clear-fix" id="contact-submit">
						<a id="contact-send" onclick="check_contact();" href="javascript:void(0);">Send</a>
                        <input type="submit" value="send_contact" id="send_contact" name="send_contact" style="display:none;" />
						<input type="reset" id="reset" />								
						</div>
					</fieldset>
			
                        <input type="hidden" name="option" value="com_contact" />
                    	<input type="hidden" name="view" value="contact" />
                        <input type="hidden" name="id" value="<?php echo $this->contact->id; ?>" />
                    	<input type="hidden" name="task" value="submit" />
                    	<?php echo JHTML::_( 'form.token' ); ?>
            	</form>
			</div><!--  end contact right -->
		</div>
	</div>
<script>
    $('#reset').click(function(e){
     e.preventDefault(); 
     $("#kontaktperson").attr("value","Kontaktperson");
     $("#email").attr("value","Email");
     $("#navn").attr("value","Firma/navn");
     $("#emne").attr("value","Emne");
     $("#text").attr("value","Din besked");
     return false;
    });
</script>

<script type="text/javascript">
	$(document).ready(function(){
	
    check_contact=function(){
        
        if(($('#kontaktperson').attr("value") == "" )|| ($('#kontaktperson').attr("value") == "Kontaktperson")){
            $('#alert').html('Udfyld venligst kontaktperson ');
            $('#backoverlay').show();
            $('#show_popup').show();
            $('#f_focus').html('kontaktperson');
            return false;	
        }
        
        if(($('#email').attr("value") == "" )|| ($('#email').attr("value") == "Email")){
            $('#alert').html('Udfyld venligst email');
            $('#backoverlay').show();
            $('#show_popup').show();
            $('#f_focus').html('email');
            return false;	
        }
        
        else{
            if(!isEmail($('#email').val())){
                $('#alert').html('Venligst e-mail er gyldig');
                $('#backoverlay').show();
                $('#show_popup').show();
                $('#s_focus').html('email');
                return false; 
            }
        }
        
        if(($('#navn').attr("value") == "" )|| ($('#navn').attr("value") == "Firma/navn")){
            $('#alert').html('Udfyld venligst navn ');
            $('#backoverlay').show();
            $('#show_popup').show();
            $('#f_focus').html('navn');
            return false;	
        }
        
        if(($('#emne').attr("value") == "" )|| ($('#emne').attr("value") == "Emne")){
            $('#alert').html('Udfyld venligst emne ');
            $('#backoverlay').show();
            $('#show_popup').show();
            $('#f_focus').html('emne');
            return false;	
        }
        		
      if(($('#text').attr("value") == "" )|| ($('#text').attr("value") == "Din besked")){
			$('#alert').html('Udfyld venligst din besked');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('text');
			return false;	
		}
            
        //$('#com_form_login').submit();
        $('#send_contact').click();
        
        return true;
	};    
     isEmail=function(string) {
		if (string.search(/^\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			return true;
		else return false;
    };
    close_popup=function(){		
		var fel=$('#f_focus').html();
        $('#backoverlay').hide();
		$('#show_popup').hide();
		$('#' + fel ).focus();
	};
    
    });

</script> 